# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
from pymongo.errors import DuplicateKeyError

from rankinglistspider.db import db


class RankingListSpiderPipeline(object):

    def process_item(self, item, spider):

        try:
            if item['desc']:
                db.ranking_data.insert(item)
        except DuplicateKeyError:
            spider.log('DuplicateKeyError')
        return item
